#include <Core/logger/logger.h>
#include "sslclient.h"
#include "common.h"
//#include <protocol/message.h>

namespace Opl
{
    namespace Helpers
    {
        class SslClientPrivate
        {
            public:
                SslClientPrivate()
                {}
                ~SslClientPrivate() {}
                QString host;
                int port;
        };


        SslClient::SslClient(const QString& host, int port) :
            Ssl::SslBase(0), O_PRIVATE_CREATE(SslClient)
        {
            O_D(SslClient);
            d->host = host;
            d->port = port;
            LI.Debug(QString("Create SslClient:%1:%2").arg(host).arg(port));
        }

        SslClient::~SslClient()
        {
            O_PRIVATE_DELETE;
        }

        void SslClient::start()
        {
            O_D(SslClient);
            LI.Info(QString("SslClient::start(host=%1, port=%2)").arg(d->host).arg(d->port));
            Ssl::SslBase::start();
            //socket()->connectToHostEncrypted(d->host, d->port);
            socket()->connectToHost(d->host, d->port);
            setStatusInternal(Connecting);
        }

    }
}
